import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Scanner;


/**
 * 
 * @author Enzo
 *
 * Modularizes the to-do list part of the main screen
 *
 *Functions:
 *	Add more toDo items
 *	Remove toDo items
 *	Edit toDo items
 *	
 *	
 */
public class DataManagement {

	static File dataFile;
	static ArrayList<ToDoItem> toDoList = new ArrayList<ToDoItem>();
	
	
	
	static void loadDataFile(){
		dataFile = new File("ToDoDataFile.txt");
		Scanner inputScanner = null;
		
		//Create a scanner for data file
		try {
			inputScanner = new Scanner(dataFile);
		} catch (FileNotFoundException e) {
			MainFrameGUI.createGUIPopUpError("No File found!" +e.getLocalizedMessage());
			e.printStackTrace();
		}
		
		//Read in all the data
		while(inputScanner.hasNext()){
			
		
		}
	}
	static void saveNewToDoItem(ToDoItem ToDoItemParam){
		
	}
	
	//Public methods------------------------------------------------
	static void createNewToDoItem(Date date, String toDoString, int priority){
		ToDoItem newItem = new ToDoItem(date, toDoString, priority);
		toDoList.add(newItem);
		Collections.sort(toDoList);
		
		MainFrameGUI.displayDebug("------------Finished Sorting------------");
		for (int i=0; i <toDoList.size(); i++){
			MainFrameGUI.displayDebug(toDoList.get(i).getToDoString());
		}
	}
	public static void createNewToDoItem(ToDoItem newItem) {
		toDoList.add(newItem);
		Collections.sort(toDoList);
		
		MainFrameGUI.displayDebug("------------Finished Sorting------------");
		for (int i=0; i <toDoList.size(); i++){
			MainFrameGUI.displayDebug(toDoList.get(i).getToDoString());
		}
	}
	
	
	
	
	
	
	
	public ArrayList<ToDoItem> getToDoList() {
		return toDoList;
	}

	public void setToDoList(ArrayList<ToDoItem> toDoList) {
		this.toDoList = toDoList;
	}
	
}
